package com.haixee.parkdemo.logistics.service;

import com.haixee.parkdemo.common.exception.BusinessException;
import com.haixee.parkdemo.common.response.CommonResEnum;
import com.haixee.parkdemo.data_acl.mybatis.DataAclHelper;
import com.haixee.parkdemo.logistics.dao.ContentCustomMapper;
import com.haixee.parkdemo.logistics.dao.ContentMapper;
import com.haixee.parkdemo.logistics.model.Content;
import com.haixee.parkdemo.logistics.service.impl.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ContentServiceImpl implements ContentService {

    @Autowired
    private ContentMapper contentMapper;

    @Autowired
    private ContentCustomMapper contentCustomMapper;

    @Override
    public List<Content> select() {

        DataAclHelper.start();
        return contentCustomMapper.selectAll();
    }

    @Override
    public void updateContent(Content content) {

        DataAclHelper.start();
        int updateRow = contentMapper.updateByPrimaryKeySelective(content);
        if (updateRow == 0) {
            throw new BusinessException(CommonResEnum.PERMISSION_DENIED);
        }
    }
}
